package com.elock.job;

import java.util.Calendar;
import java.util.Date;

import javax.annotation.Resource;

import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.elock.base.core.util.LogUtils;
import com.elock.service.TerminalNotifyMessageService;

@Component("terminalNotifyMessageJob")
@Lazy(false)
public class TerminalNotifyMessageJob {

	@Resource(name = "terminalNotifyMessageServiceImpl")
	private TerminalNotifyMessageService terminalNotifyMessageService;

	@Scheduled(cron = "0 0 0/2 * * ?")
	public void processNotifyMessage() {

		try {
			Calendar cal = Calendar.getInstance();
			cal.setTime(new Date());
			cal.add(Calendar.HOUR_OF_DAY, -2);
			Date searchTime = cal.getTime();
			terminalNotifyMessageService.updateProcessResult(null,
					"超时2小时未执行，通知取消",
					"",
					searchTime);
		}
		catch (Exception e) {
			LogUtils.error("调度更新消息通知", e);
		}
	}
}
